#ifndef ServerRiotShield_H
#define ServerRiotShield_H

#include "RiotShield.h"
#include "Engine.h"
#include "InputSet.h"
#include "MotionState.h"
#include <OgreEntity.h>
#include "PlayingFieldConstants.h"
#include "NetworkTarget.h"
#include "NetworkUtils.h"

#define MSGSIZE 64

//a riot shield for the player to control
class ServerRiotShield : public RiotShield, public NetworkTarget {
public:
	ServerRiotShield(char* name, Ogre::SceneManager* sm, Ogre::SceneNode* toAddTo, NetworkHandler *toSend, int target, int ID) : RiotShield(name, sm, toAddTo, 0){
		cUpPressed = 0;
		cDownPressed = 0;
		cRightPressed = 0;
		cLeftPressed = 0;
		pthread_mutex_init(&shieldLock, NULL);
		handler = toSend;
		tgt = target;
		myID = ID;
	}
	virtual void runLogic();
	virtual void messageUpdate(char *message, int length);
protected:
	//used for server side calculations
	bool cUpPressed;
	bool cDownPressed;
	bool cRightPressed;
	bool cLeftPressed;
	//used to synchronize access to the above members
	pthread_mutex_t shieldLock;
	//used to send state information from the server
	NetworkHandler *handler;
	int tgt;
	char buffer[MSGSIZE];
	Converter conv;
	int myID;
};

#endif
